<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/react.development.js"></script>
    <script src="js/react-dom.development.js"></script>
    <script src="js/babel.min.js"></script>
</head>
<body>
    <div id="app"></div>

    <script type='text/babel'>
       class Welcome extends React.Component{
           constructor(props){
               super(props);
               this.state={
                   count:0
               }
           }
           increment(){
                this.setState({
                   count:this.state.count +1
                })
           }
           decrement(){
               this.setState({
                count:this.state.count-1
               })
           }
           render() {
            return(
                <div>
                    <h3>欢迎{this.props.name}第{this.state.count}视察工作</h3>
                    <button onClick={this.increment.bind(this)}>增加</button>
                    <button onClick={e=>this.decrement()}>减少</button>
                </div>
              )
           }
       }
       ReactDOM.render(<Welcome name='李达康' />,document.getElementById('app'))



        //     function Clock(props) {
        //             return (
        //                 <div>
        //                 <h1>Hello, world!</h1>
        //                 <h2>It is {props.date.toLocaleTimeString()}.</h2>
        //                 </div>
        //             );
        // }

        // function tick() {
        //     ReactDOM.render(
        //         <Clock date={new Date()} />,
        //         document.getElementById('app')
        //     );
        // }

        // setInterval(tick, 1000);
    </script>
</body>
</html>